home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
dnalib59.arj
/
ASK.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-12-29
|
7KB
|
221 lines
DECLARE SUB Popwind(Title$,Toprow%,Leftcolumn%,Bottomrow%,Rightcolumn%,Attr%, Shadow%, Border%)
DECLARE SUB SaveScreen(ScreenID$,TopRow%,LeftColumn%,BottomRow%,RightColumn%,Shadow%)
DECLARE SUB RestoreScreen(ScreenID$,TopRow%,LeftColumn%)
DECLARE SUB CalcByte(Attr%,LowByte%,HiByte%)
DECLARE SUB Clicked(Rgt%,Lft%,Row%,Col%)
DECLARE SUB HideCursor()
DECLARE SUB ShowCursor()
DECLARE FUNCTION LeftButtonReleased%()
SUB ASK(Text$,Mouse%,Rtrn%,Location%,Button%,Push%,Attr%,Shadow%,Border%) PUBLIC
CalcByte Attr%,FGround%,BGround%
IF Mouse% THEN HideCursor
X% = LEN (Text$) AND 1
IF X% = 0 THEN 'see if the string is odd or even
Prompt$ = Text$
ELSE
Prompt$ = Text$ + CHR$(63) 'if it's odd add a question mark
END IF
IF LEN (Prompt$) <= 28 THEN 'only size the box if the string
Size% = 32 'is less than 28 characters
ELSEIF LEN (Prompt$) >= 28 THEN
Size% = LEN (Prompt$) + 4 'make the box fit the string
END IF
IF Rtrn% = 0 THEN 'set up the defaults
A$ = "No" 'and somthing to Test against
Test% = 1
ELSEIF Rtrn% = 1 THEN
A$ = "Ok"
Test% = 0
END IF
'┌─────────────────────────────────────────────────────────────────────┐
'│ The following block of code places the window on screen with a │░░
'│ call to POPWIND, prints the buttons and allows the user to move │░░
'│ between choices using the left and right arrow keys, by either │░░
'│ INCRementing or DECRementing the variable Pointer%. │░░
'└─────────────────────────────────────────────────────────────────────┘░░
' ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
SaveScreen AskScreen$,Location%, 40 - (Size% / 2), Location% + 5, 40 + (Size% / 2) - 1, Shadow%
Popwind Title$,Location%, 40 - (Size% / 2), Location% + 5, 40 + (Size% / 2) - 1, Attr%, Shadow%, Border%
Pointer% = 1
LOCATE Location% + 1, 40 - LEN (Prompt$) / 2,0
COLOR Fground%, Bground%
PRINT Prompt$;
PrintRoutine:
DO
Row% = Location% + 2
Col% = 26
COLOR Button%, Bground%
LOCATE Row%, Col%,0
SELECT CASE Pointer%
CASE 1
PRINT "╔════════╗ ┌────┐ ┌────────┐";
LOCATE Row% + 1, Col%,0
PRINT "║ <────┘ ║ │ " + A$ + " │ │ CANCEL │";
LOCATE Row% + 2, Col%,0
PRINT "╚════════╝ └────┘ └────────┘";
CASE 2
PRINT "┌────────┐ ╔════╗ ┌────────┐";
LOCATE Row% + 1, Col%,0
PRINT "│ <────┘ │ ║ " + A$ + " ║ │ CANCEL │";
LOCATE Row% + 2, Col%,0
PRINT "└────────┘ ╚════╝ └────────┘";
CASE 3
PRINT "┌────────┐ ┌────┐ ╔════════╗";
LOCATE Row% + 1, Col%,0
PRINT "│ <────┘ │ │ " + A$ + " │ ║ CANCEL ║";
LOCATE Row% + 2, Col%,0
PRINT "└────────┘ └────┘ ╚════════╝";
END SELECT
WHILE NOT INSTAT
IF Mouse% THEN
ShowCursor
Rgt% = 0:Lft% = 0
Clicked Rgt%,Lft%,MRow%,MCol%
IF Lft% AND MRow% >= Row% AND MRow% <= Row% + 2 THEN
IF LeftButtonReleased% THEN
Chose% = 13
HideCursor
GOTO KeyBoardRoutine
ELSE
SELECT CASE MCol%
CASE Col% TO Col% + 9
Pointer% = 1
HideCursor
GOTO PrintRoutine
CASE Col% + 11 TO Col% + 16
Pointer% = 2
HideCursor
GOTO PrintRoutine
CASE Col% + 18 TO Col% + 27
Pointer% = 3
HideCursor
GOTO PrintRoutine
END SELECT
END IF
ELSEIF Rgt% THEN
HideCursor
Chose% = 27
GOTO KeyBoardRoutine
END IF
END IF
WEND
Ky$ = INKEY$
IF LEN(Ky$) = 1 THEN
Chose% = ASC(Ky$)
ELSE
Chose% = -ASC(RIGHT$(Ky$,1))
END IF
'┌─────────────────────────────────────────────────────────────────────┐
'│ The second SELECT CASE uses the variable Pointer% to decide which │░░
'│ Button to hilite after a selection has been made by hitting the │░░
'│ Enter key, if an arrow key is pressed then Pointer% is INCR or │░░
'│ DECR and LOOPs to the top of the loop and the Buttons are PRINTed │░░
'│ in there new arrangement, and waits for a key stroke. │░░
'└─────────────────────────────────────────────────────────────────────┘░░
' ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
KeyBoardRoutine:
IF Mouse% THEN HideCursor
SELECT CASE Chose%
CASE 13 'enter key
COLOR Push%, Bground%
SELECT CASE Pointer%
CASE 1
LOCATE Row%, Col%,0
PRINT "╔════════╗";
LOCATE Row% + 1, Col%,0
PRINT "║ <────┘ ║";
LOCATE Row% + 2, Col%,0
PRINT "╚════════╝";
CASE 2
LOCATE Row%, Col% + 11,0
PRINT "╔════╗";
LOCATE Row% + 1, Col% + 11,0
PRINT "║ " + A$ + " ║";
LOCATE Row% + 2, Col% + 11,0
PRINT "╚════╝";
Rtrn% = Test%
CASE 3
LOCATE Row%, Col% + 18,0
PRINT "╔════════╗";
LOCATE Row% + 1, Col% + 18,0
PRINT "║ CANCEL ║";
LOCATE Row% + 2, Col% + 18,0
PRINT "╚════════╝";
Rtrn% = 2
END SELECT
SelectionMade% = 1
CASE 27 'Esc key
COLOR Button%, Bground%
LOCATE Row%, Col%,0
PRINT "┌────────┐ ┌────┐";
LOCATE Row% + 1, Col%,0
PRINT "│ <────┘ │ │ " + A$ + " │";
LOCATE Row% + 2, Col%,0
PRINT "└────────┘ └────┘";
COLOR Push%, Bground%
LOCATE Row%, Col% + 18,0
PRINT "╔════════╗";
LOCATE Row% + 1, Col% + 18,0
PRINT "║ CANCEL ║";
LOCATE Row% + 2, Col% + 18,0
PRINT "╚════════╝";
Rtrn% = 2
SelectionMade% = 1
CASE -75 'left arrow
IF Pointer% > 1 THEN
DECR Pointer%
ELSE
Pointer% = 3
END IF
CASE -77 'right arrow
IF Pointer% < 3 THEN
INCR Pointer%
ELSE
Pointer% = 1
END IF
CASE ELSE
BEEP
END SELECT
LOOP UNTIL SelectionMade% = 1
DELAY .5
RestoreScreen AskScreen$,Location%, 40 - (Size% / 2)
END SUB